package br.com.fidalgotecnologia.layar.json;

import org.json.JSONException;
import org.json.JSONObject;

import br.com.fidalgotecnologia.layar.entity.Action;



public class ActionJson {
	public static ActionJson instance;
	
	public static ActionJson getInstance() {
		if(instance==null){
			instance= new ActionJson();
		}
		return instance;
	}
	
	public JSONObject toObject(Action action){
		JSONObject actionJson = new JSONObject();
		try {
			actionJson.put("uri", action.getUri());
			actionJson.put("label", action.getLabel());
			actionJson.put("contentType", action.getContentType());
			actionJson.put("method", action.getMethod());
			actionJson.put("params", action.getParams());
			actionJson.put("closeBiw", action.isCloseBiw());
			actionJson.put("activityType", action.getActivityType());
			actionJson.put("showActivity", action.isShowActivity());
			actionJson.put("activityMessage", action.getActivityMessage());
			actionJson.put("autoTriggerRange", action.getAutoTriggerRange());
			actionJson.put("autoTriggerOnly", action.isAutoTriggerOnly());
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return actionJson;
	}
}
